//
// Created by Hello on 2024/2/9.
//

// 采用迭代没方法将递归转换为非递归
class Solution {
public:
    int fib(int n) {
        if(n == 0 || n == 1)
            return n;
        int a = 0, b = 1, c;
        for(int i = 2; i <= n; i++)
        {
            c = a + b;
            a = b;
            b = c;
        }
        return c;
    }
};